package com.edu.whty.controller;

import com.edu.whty.common.constants.CodeConstants;
import com.edu.whty.entity.base.ResponseEntity;
import com.edu.whty.entity.interact.InteractResource;
import com.edu.whty.service.InteractResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/interact")
public class InteractController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    InteractResourceService interactResourceService;

    @RequestMapping(value = "/getInteractResource", method = RequestMethod.POST)
    public ResponseEntity list(@RequestBody InteractResource param) {
        if (null == param) {
                return ResponseEntity.getFailedResponse(CodeConstants.CONSTANT_RETURN_CODE_SYSTEM_ERROR, "参数不能为空");
            } else {
                if (org.apache.commons.lang.StringUtils.isEmpty(param.getInteractNameEn())) {
                    return ResponseEntity.getFailedResponse(CodeConstants.CONSTANT_RETURN_CODE_SYSTEM_ERROR, "interactNameEn不能为空");
                }

                Map<String, Object> result = interactResourceService.getInteractResource(param);
                return ResponseEntity.getSuccessResponse(result);
            }
    }
}
